import 'dart:convert' show json;

import 'package:flutter_data_json_app/base/base_bean.dart';

class DeliverDetails extends BaseBean{

  String goodsTypeName;
  DeliverBean deliver;
  OwnerInfo ownerInfo;

  DeliverDetails.fromParams({this.goodsTypeName, this.deliver, this.ownerInfo});

  factory DeliverDetails(jsonStr) => jsonStr == null ? DeliverDetails.fromParams() : jsonStr is String ? new DeliverDetails.fromJson(json.decode(jsonStr)) : new DeliverDetails.fromJson(jsonStr);

  DeliverDetails.fromJson(jsonRes) {
    goodsTypeName = jsonRes['goodsTypeName'];
    deliver = jsonRes['deliver'] == null ? null : new DeliverBean.fromJson(jsonRes['deliver']);
    ownerInfo = jsonRes['ownerInfo'] == null ? null : new OwnerInfo.fromJson(jsonRes['ownerInfo']);
  }

  @override
  String toString() {
    return '{"goodsTypeName": ${goodsTypeName != null?'${json.encode(goodsTypeName)}':'null'},"deliver": $deliver,"ownerInfo": $ownerInfo}';
  }

  @override
  fromJson(jsonRes) {
    // TODO: implement fromJson
    return DeliverBean.fromJson(jsonRes);
  }

  @override
  bool dataIsEmpty() {
    // TODO: implement dataIsEmpty
    return false;
  }
}

class OwnerInfo {

  int finishCount;
  int registerTime;
  String appraise;
  String ownerName;
  String ownerPicture;

  OwnerInfo.fromParams({this.finishCount, this.registerTime, this.appraise, this.ownerName, this.ownerPicture});

  OwnerInfo.fromJson(jsonRes) {
    finishCount = jsonRes['finishCount'];
    registerTime = jsonRes['registerTime'];
    appraise = jsonRes['appraise'];
    ownerName = jsonRes['ownerName'];
    ownerPicture = jsonRes['ownerPicture'];
  }

  @override
  String toString() {
    return '{"finishCount": $finishCount,"registerTime": $registerTime,"appraise": ${appraise != null?'${json.encode(appraise)}':'null'},"ownerName": ${ownerName != null?'${json.encode(ownerName)}':'null'},"ownerPicture": ${ownerPicture != null?'${json.encode(ownerPicture)}':'null'}}';
  }
}

class DeliverBean {

  int createTime;
  int id;
  int loadTime;
  int ownerId;
  int srcCityId;
  int srcDistrictId;
  int status;
  int targetCityId;
  int targetDistrictId;
  int updateTime;
  int weight;
  double srcLatitude;
  double srcLongitude;
  double targetLatitude;
  double targetLongitude;
  double transAmount;
  String contactPerson;
  String deliverNo;
  String goodsName;
  String goodsType;
  String mobile;
  String remark;
  String srcAddr;
  String srcCityName;
  String srcDistrictName;
  String targetAddr;
  String targetCityName;
  String targetDistrictName;

  DeliverBean.fromParams({this.createTime, this.id, this.loadTime, this.ownerId, this.srcCityId, this.srcDistrictId, this.status, this.targetCityId, this.targetDistrictId, this.updateTime, this.weight, this.srcLatitude, this.srcLongitude, this.targetLatitude, this.targetLongitude, this.transAmount, this.contactPerson, this.deliverNo, this.goodsName, this.goodsType, this.mobile, this.remark, this.srcAddr, this.srcCityName, this.srcDistrictName, this.targetAddr, this.targetCityName, this.targetDistrictName});

  DeliverBean.fromJson(jsonRes) {
    createTime = jsonRes['createTime'];
    id = jsonRes['id'];
    loadTime = jsonRes['loadTime'];
    ownerId = jsonRes['ownerId'];
    srcCityId = jsonRes['srcCityId'];
    srcDistrictId = jsonRes['srcDistrictId'];
    status = jsonRes['status'];
    targetCityId = jsonRes['targetCityId'];
    targetDistrictId = jsonRes['targetDistrictId'];
    updateTime = jsonRes['updateTime'];
    weight = jsonRes['weight'];
    srcLatitude = jsonRes['srcLatitude'];
    srcLongitude = jsonRes['srcLongitude'];
    targetLatitude = jsonRes['targetLatitude'];
    targetLongitude = jsonRes['targetLongitude'];
    transAmount = jsonRes['transAmount'];
    contactPerson = jsonRes['contactPerson'];
    deliverNo = jsonRes['deliverNo'];
    goodsName = jsonRes['goodsName'];
    goodsType = jsonRes['goodsType'];
    mobile = jsonRes['mobile'];
    remark = jsonRes['remark'];
    srcAddr = jsonRes['srcAddr'];
    srcCityName = jsonRes['srcCityName'];
    srcDistrictName = jsonRes['srcDistrictName'];
    targetAddr = jsonRes['targetAddr'];
    targetCityName = jsonRes['targetCityName'];
    targetDistrictName = jsonRes['targetDistrictName'];
  }

  @override
  String toString() {
    return '{"createTime": $createTime,"id": $id,"loadTime": $loadTime,"ownerId": $ownerId,"srcCityId": $srcCityId,"srcDistrictId": $srcDistrictId,"status": $status,"targetCityId": $targetCityId,"targetDistrictId": $targetDistrictId,"updateTime": $updateTime,"weight": $weight,"srcLatitude": $srcLatitude,"srcLongitude": $srcLongitude,"targetLatitude": $targetLatitude,"targetLongitude": $targetLongitude,"transAmount": $transAmount,"contactPerson": ${contactPerson != null?'${json.encode(contactPerson)}':'null'},"deliverNo": ${deliverNo != null?'${json.encode(deliverNo)}':'null'},"goodsName": ${goodsName != null?'${json.encode(goodsName)}':'null'},"goodsType": ${goodsType != null?'${json.encode(goodsType)}':'null'},"mobile": ${mobile != null?'${json.encode(mobile)}':'null'},"remark": ${remark != null?'${json.encode(remark)}':'null'},"srcAddr": ${srcAddr != null?'${json.encode(srcAddr)}':'null'},"srcCityName": ${srcCityName != null?'${json.encode(srcCityName)}':'null'},"srcDistrictName": ${srcDistrictName != null?'${json.encode(srcDistrictName)}':'null'},"targetAddr": ${targetAddr != null?'${json.encode(targetAddr)}':'null'},"targetCityName": ${targetCityName != null?'${json.encode(targetCityName)}':'null'},"targetDistrictName": ${targetDistrictName != null?'${json.encode(targetDistrictName)}':'null'}}';
  }
}

